package com.ruoyi.chengkao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.chengkao.domain.CkEducation;
import com.ruoyi.chengkao.service.ICkEducationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文化程度信息Controller
 * 
 * @author xiaosong
 * @date 2025-03-10
 */
@Api(tags = "成人高考-文化程度管理")
@RestController
@RequestMapping("/chengkao/CKeducation")
public class CkEducationController extends BaseController
{
    @Autowired
    private ICkEducationService ckEducationService;

    /**
     * 查询文化程度信息列表
     */
    @ApiOperation("成人高考文化程度信息管理 - 分页查询列表")
    @PreAuthorize("@ss.hasPermi('chengkao:CKeducation:list')")
    @GetMapping("/list")
    public TableDataInfo list(CkEducation ckEducation)
    {
        startPage();
        List<CkEducation> list = ckEducationService.selectCkEducationList(ckEducation);
        return getDataTable(list);
    }

   //查询数据全部接口，
    @ApiOperation("成人高考文化程度信息管理 - 查询所有数据")
    @GetMapping("/all")
    public AjaxResult getAll()
    {
        List<CkEducation> list = ckEducationService.selectCkEducationAll();
        return success(list);
    }

    /**
     * 导出文化程度信息列表
     */
    @ApiOperation("成人高考文化程度信息管理 - 导出数据")
    @PreAuthorize("@ss.hasPermi('chengkao:CKeducation:export')")
    @Log(title = "文化程度信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CkEducation ckEducation)
    {
        List<CkEducation> list = ckEducationService.selectCkEducationList(ckEducation);
        ExcelUtil<CkEducation> util = new ExcelUtil<CkEducation>(CkEducation.class);
        util.exportExcel(response, list, "文化程度信息数据");
    }

    /**
     * 获取文化程度信息详细信息
     */
    @ApiOperation("成人高考文化程度信息管理 - 根据ID获取详细信息")
//    @PreAuthorize("@ss.hasPermi('chengkao:CKeducation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ckEducationService.selectCkEducationById(id));
    }

    /**
     * 新增文化程度信息
     */
    @ApiOperation("成人高考文化程度信息管理 - 新增数据")
    @PreAuthorize("@ss.hasPermi('chengkao:CKeducation:add')")
    @Log(title = "文化程度信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CkEducation ckEducation)
    {
        return toAjax(ckEducationService.insertCkEducation(ckEducation));
    }

    /**
     * 修改文化程度信息
     */
    @ApiOperation("成人高考文化程度信息管理 - 修改数据")
    @PreAuthorize("@ss.hasPermi('chengkao:CKeducation:edit')")
    @Log(title = "文化程度信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CkEducation ckEducation)
    {
        return toAjax(ckEducationService.updateCkEducation(ckEducation));
    }

    /**
     * 删除文化程度信息
     */
    @ApiOperation("成人高考文化程度信息管理 - 删除数据")
    @PreAuthorize("@ss.hasPermi('chengkao:CKeducation:remove')")
    @Log(title = "文化程度信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ckEducationService.deleteCkEducationByIds(ids));
    }
}
